window.onbeforeunload = function (e) { 
	 teste();	
};
var myclose = false;

function teste(){
	
	var evt = "";
	if(navigator.appName.indexOf('Internet Explorer') > 0){
	
		evt = e ? e:window.event;	
		
		if (evt.clientY < 0 || evt.clientX < 0 )  {  
			setTimeout('myclose=false',100);  
			myclose = true; 
		}  else {
		
			var keyVals = document.getElementById('ffKeyTrap');
        	if(keyVals.value == 'true115'){
        		setTimeout('myclose=false',100);  
        		myclose = true; 			
        	}
		}
		
	} else {
		
		
		evt = e || window.event;
		

		
		if (evt.screenX  < 0 || evt.screenY  < 0 )  {  
		
			setTimeout('myclose=false',100);  
			myclose = true; 
		}  else {
		
			var keyVals = document.getElementById('ffKeyTrap');
        	if(keyVals.value == 'true115'){
        		setTimeout('myclose=false',100);  
        		myclose = true; 			
        	}
		}
		

	}
	
	
}

window.onunload = function () { 
	teste2();	
};

function teste2(){
	//alert("entrou no teste2");
	if (myclose==true)   {  
		
		teste3();
	}  
}

function teste3(){
	alert("Window is closed"); 
} 
